<template>
  <a-card shadow="never" class="!border-none">
    <div class="font-medium mb-7">基本设置</div>
    <a-form ref="formRef" :model="formData">
      <a-form-item label="用户默认头像">
        <div>
<!--          <material-picker v-model="formData.default_avatar" :limit="1" />-->
        </div>
      </a-form-item>
      <a-form-item>
        <div>
          <div class="form-tips">
            用户注册时给的默认头像，建议尺寸：400*400像素，支持jpg，jpeg，png格式
          </div>
        </div>
      </a-form-item>

      <a-button type="primary" @click="handleSubmit">保存</a-button>
    </a-form>
  </a-card>
</template>

<script setup lang="ts">
import {reactive} from 'vue'
// 表单数据
const formData = reactive({
  default_avatar: '' // 用户默认头像
})


// 获取用户设置数据
const getData = async () => {
  try {
    const data = await getUserSetup()
    for (const key in formData) {
      //@ts-ignore
      formData[key] = data[key]
    }
  } catch (error) {
    console.log('获取=>', error)
  }
}

// 保存用户设置数据
const handleSubmit = async () => {
  try {
    await setUserSetup(formData)
    getData()
  } catch (error) {
    console.log('保存=>', error)
  }
}

getData()
</script>

<style scoped lang="less">

</style>
